Contents
Sometimes you need to do actions as root to configure things for your AMI.
SSH login user
Firstly login as as the regular user for your AMI instance.
Username: ubuntu or Username: centos
No password is used. You should connect to your instance using the public IP address and your public key
ssh -i mykey.pem ubuntu@public-ip or ssh -i mykey.pem centos@public-ip
Becoming a super user
There is no root login for security reasons. If you want to do things as root then you can use the sudo command once you are logged in as the user ubuntu or centos, for example:
sudo ls /etc sudo rm /tmp/test.file
and even give yourself a root shell by doing
sudo bash
Be very careful with root access as it has total access to the system and you could end up deleting an important file by mistake.
Changing the file ownership
If you create files or directories as root you will out likely need to change the ownership to the same user and group as the rest of the files in that same directory (for example www-data).
chown www-data:www-data my-file